package 字节码文件.算数指令;

import org.junit.Test;

/**
 * <P> @Author: ideaAdmin
 * <P> TODO: Class
 * <P> TODO: 算数指令
 * <P> Date: 2022/3/26:17:01
 * <P> Description:
 */

public class ArithmeticTest {
    @Test
    public void method1() {
        int i = 10;
        double j = i / 0.0;
        System.out.println(j);//Infinity 无穷大

        double d1 = 0.0;
        double d2 = d1 / 0.0;
        System.out.println(d2);//NaN not a number
    }

    public void method2() {
        float i = 10;
        float j = -i;
        i = -j;
    }

    public void method3() {
        int i = 100;
        //  i = i+100;
        i += 10; //自增  iinc 1 by 10 让下标为1的 自增10
    }

    public int method4() {
        int a = 80;
        int b = 7;
        int c = 10;
        return (a + b) * c;
    }

    public int method5(int i, int j) {
        return (i + j - 1) & ~(j - 1);
    }

    public void method6(int i, int j) {
        i = i << 6;
    }

    public void method7() {
        int i = 10;
        // i++;//iinc 1 by 1
        ++i; // iinc 1 by 1
    }

    public void method8() {
        int i = 10;
        int a = i++;

        int j = 20;
        int b = ++j;
    }

    @Test
    public void method9() {
        int i = 10;
        i = i++;
        System.out.println(i);
    }

}
